<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:exslt="http://exslt.org/common"
  xmlns:func="http://exslt.org/functions"
  xmlns:date="http://exslt.org/dates-and-times"
  xmlns:url="http://xmlns.heustics.org/xslt/ext/urllib/0.1/"
  xmlns:w="http://xmlns.heustics.org/xslt/ext/wiki/0.1/"  
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:s="http://xmlns.heustics.org/xslt/ext/strings/0.1/"
  xmlns:a="&a;"
  xmlns:o="&a;search#"
  xmlns:dt="&a;dates#"
  xmlns:e="&a;editor-common#"
  xmlns:fres="http://xmlns.4suite.org/reserved"
  extension-element-prefixes="url func w"
  exclude-result-prefixes="xsl exslt func date url o e a l s dt fres"
> 
  <!-- xsl:import href="layout.xslt"/ -->
  <xsl:import href="basic.xslt"/>
  <xsl:import href="dates.xslt"/>
  <xsl:import href="options.xslt"/>
  <xsl:import href="editor-common.xslt"/>
  <xsl:import href="lang-region.xslt"/>
  
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;search')"/>
  <xsl:variable name="o:params-l10n" select="$o:l10n/l:context[@name='params']/*"/>
  <xsl:variable name="o:hints-l10n" select="$o:l10n/l:context[@name='hints']/*"/> 
  <xsl:variable name="o:submits-l10n" select="$o:l10n/l:context[@name='submits']/*"/>
  <xsl:variable name="o:nav-l10n" select="$o:l10n/l:context[@name='nav']/*"/> 
  
  <xsl:variable name="o:theme" select="a:get-l10n('&a;search#base-theme')"/>
  
  <xsl:variable name="o:dates-l10n" select="a:get-l10n('&a;dates')"/>    
        
  <func:function name="o:get-search-nav-range">
    <xsl:param name="range" select="$fres:config-doc/a:Params/@default-search-nav-range"/>
    <xsl:choose>
      <xsl:when test="$range">
        <func:result select="number($range)"/>
      </xsl:when>
      <xsl:otherwise>
        <func:result select="5"/>
      </xsl:otherwise>
    </xsl:choose>
  </func:function>
  
  <xsl:template match="a:languages" mode="a:select">
    <xsl:param name="selected"/>
    <xsl:param name='l10n'/>    
    <option value=''>
      <xsl:if test='@selected = ""'>
        <xsl:attribute name='selected'>selected</xsl:attribute>
      </xsl:if>
      <xsl:value-of select="$l10n/l:gentext[@key='any']"/>
    </option>  
    <xsl:choose>
      <xsl:when test="count(*) &gt; 1">
        <xsl:apply-templates mode="a:select">
          <xsl:with-param name="selected" select="$selected"/>
          <xsl:with-param name="l10n" select="$l10n"/>
        </xsl:apply-templates>
      </xsl:when>      
      <xsl:otherwise>
        <xsl:apply-templates mode="a:select-single">
          <xsl:with-param name="selected" select="$selected"/>
          <xsl:with-param name="l10n" select="$l10n"/>
        </xsl:apply-templates>
      </xsl:otherwise>
    </xsl:choose>     
  </xsl:template>
  
  <xsl:template match="a:form" mode="a:form-header">
    <xsl:param name="key" select="@status-type"/>
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='status-types']/*"/>
    <xsl:variable name="status" select="$l10n[@key=$key]"/>
    <xsl:choose>
      <xsl:when test="$status">
        <div class="entry status">
          <span><xsl:value-of select="$status"/></span>
          <div class="spacer"/>
        </div>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-imports/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  
  <!-- xsl:template match="a:form[@mode='main' and starts-with(@action,'search')]">
    <xsl:param name="account" select="/*/a:account"/>
    <xsl:param name="config" select="/*/a:config"/>
    <xsl:call-template name="a:main-editor-form">
      <xsl:with-param name="account" select="$account"/>
      <xsl:with-param name="config" select="$config"/>
      <xsl:with-param name="class" select="'search'"/>
    </xsl:call-template>
  </xsl:template -->
  
  <xsl:template match="a:*[@node-id]" mode="a:main-instance" name="o:main-instance">  
    <xsl:param name="event" select="/*/a:content/a:form/@event"/>
    <!-- xsl:apply-templates select="." mode="a:input-methods"/ -->
    <xsl:variable name="url">
      <xsl:apply-templates select="a:search-params" mode="a:search-url-str"/>
    </xsl:variable>
    <xsl:apply-templates mode="a:input-show">
       <xsl:with-param name="url" select="concat($url,'&amp;search=',$event,'&amp;event=',$event)"/>
       <!-- removed quick-search=1&amp; -->
    </xsl:apply-templates>   
  </xsl:template>   
  
  <xsl:template match="a:search-params" mode="a:search-url-str">
    <xsl:value-of select="a:format-repeat-request()"/>
    <xsl:apply-templates mode="a:search-url-param-str"/>
  </xsl:template>
  
  <xsl:template match="*" mode="a:search-url-param-str">
    <xsl:if test="string-length(.)">
      <xsl:value-of select="concat('&amp;',local-name(),'=',url:quote(.))"/>
    </xsl:if>
  </xsl:template>
  
  <xsl:template match="a:page|a:method" mode="a:search-url-param-str"/>
  
  <xsl:template match="*[@selected]" mode="a:search-url-param-str">
    <xsl:value-of select="concat('&amp;',local-name(),'=',url:quote(@selected))"/>
  </xsl:template>
  
  <xsl:template match="*[a:option]" mode="a:search-url-param-str">
    <xsl:variable name="name" select="local-name()"/>
    <xsl:for-each select="*[@selected]">
      <xsl:value-of select="concat('&amp;',$name,'=',url:quote(@key))"/>
    </xsl:for-each>
  </xsl:template>
  
  <xsl:template match="*[a:selection]" mode="a:search-url-param-str">
    <xsl:variable name="name" select="local-name()"/>
    <xsl:for-each select="a:selection/*">
      <xsl:value-of select="concat('&amp;',$name,'=',url:quote(@key))"/>
    </xsl:for-each>
  </xsl:template>
  
  <!-- xsl:template match="*[@selected and local-name()!='effectiveDate']" mode="a:search-url-param-str">
    <xsl:value-of select="concat('&amp;',local-name(),'=',url:quote(@selected))"/>
  </xsl:template>  
  
  <xsl:template match="a:effectiveDate" mode="a:search-url-param-str">
    <xsl:if test="@selected">
      <xsl:value-of 
        select="concat('&amp;efdFlag=1&amp;efdYr=',url:quote(@year),'&amp;efdMon=',url:quote(@mon))"/>
    </xsl:if>
  </xsl:template -->
    
  <xsl:template match="a:search-params" mode="a:input-show">    
    <xsl:apply-templates mode="a:input-hidden"/>
  </xsl:template>
  
  <xsl:template match="a:language|a:region" mode="a:input-show">
    <xsl:param name="key" select="local-name()"/>
    <xsl:call-template name="a:language-select-input">
      <xsl:with-param name="label" select="$e:params-l10n[@key=$key]"/>
      <xsl:with-param name="hint" select="$e:hints-l10n[@key=$key]"/>
    </xsl:call-template>
  </xsl:template>
  
  <!-- xsl:template match="a:document" mode="a:input-hidden"/ >
    
  <xsl:template match="a:document" mode="a:input-show">
    <xsl:param name="base-url" select="a:public-url(@uri)"/>
    <div class='input text base_node'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <xsl:value-of select="$o:l10n/l:gentext[@key='search-base']"/>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='search-base']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='value'>
        <xsl:variable name="fbase-url" select="a:format-url($base-url)"/>       
        <a href='{$fbase-url}' title="{$e:l10n/l:gentext[@key='view-this-resource']}">
          <xsl:value-of select="."/>
        </a>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
    <xsl:apply-templates select="." mode="a:input-methods">
      <xsl:with-param name="methods" select="/*/a:methods/*"/>
    </xsl:apply-templates>
  </xsl:template -->  
   
  <!-- xsl:template match="a:type[a:selection]" mode="a:input-hidden">
    <xsl:for-each select="a:selection/*">
      <input type="hidden" name="type" value="{@key}"/>
    </xsl:for-each>            
  </xsl:template>   
  
  <xsl:template match="a:type" mode="a:input-show" name="o:type">
    <div class="input select type">
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span>
            <xsl:value-of select="$o:params-l10n[@key='type']"/>
          </span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='type']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>  
      <div class="value">
        <xsl:apply-templates select="a:options" mode="a:multiple-selection">
          <xsl:with-param name="name" select="'type'"/>
          <xsl:with-param name="selection" select="a:selection/*"/>
          <xsl:with-param name="header" select="$o:hints-l10n[@key='type-expanded']"/>
          <xsl:with-param name="l10n" select="a:get-l10n('&m;class-types')/l:context[@name='plural']/*"/>
        </xsl:apply-templates>
        <div class="spacer"/>
      </div>    
      <div class="spacer"/>
    </div>
  </xsl:template -->    
    
  <xsl:template match="a:search-results" mode="a:input-show">
    <xsl:param name="url"/>
    
    <xsl:variable name="total-l10n" select="$o:l10n/l:context[@name='search-results']/*"/>
    <xsl:choose>
      <xsl:when test="@total">
        <div class="search_results">
          <div class="search_total">   
            <span>
              <xsl:value-of select="s:substitute(
                $total-l10n[@key='results-shown'],
                'start',@start,
                'end',@end,
                'total',@total)"/>    
            </span>
            <div class="spacer"/>
            <!-- xsl:value-of 
              select="concat(
                $total-l10n[@key='results-shown'],
                number(@start),
                $total-l10n[@key='through'],
                @end,
                $total-l10n[@key='of-total'],
                @total,
                $total-l10n[@key='total-results'])"/ -->
          </div>
          <div class="container_nodes">
            <ol class="container">
              <xsl:for-each select="*">
                <li>
                  <xsl:call-template name="a:even-odd-class-attr"/>
                  <xsl:apply-templates select="." mode="a:search-list">
                    <xsl:with-param name="l10n" select="$o:l10n/l:context[@name='search-list']/*"/>
                    <xsl:with-param name="theme" select="$o:theme/l:context[@name='search-list']/*"/>
                  </xsl:apply-templates>
                  <div class='spacer'/>             
                </li>
              </xsl:for-each>            
            </ol>
            <div class="spacer"/>
          </div>      
          <div class="spacer"/>
        </div>   
        <div class="search_nav">
          <div class="h3">
            <span>
              <xsl:value-of select="$o:l10n/l:gentext[@key='result-page']"/>
            </span>
            <div class="spacer"/>
          </div>
          <ul>     
            <xsl:call-template name="a:search-navigation">
              <xsl:with-param name="page" select="number(@page)"/>
              <xsl:with-param name="count" select="number(@count)"/>
              <xsl:with-param name="total" select="number(@total)"/>
              <xsl:with-param name="url" select="$url"/>        
            </xsl:call-template>    
          </ul>
          <div class="spacer"/>
        </div>    
      </xsl:when>
      <xsl:otherwise>
        <div class="search_results">
          <xsl:value-of select="$total-l10n[@key='no-results']"/>
        </div>
      </xsl:otherwise>
    </xsl:choose>  
  </xsl:template>
  
  <func:function name="a:search-start-range-nav">
    <xsl:param name="page"/>
    <xsl:param name="range" select="o:get-search-nav-range()"/>
    <xsl:variable name="res" select="$page - $range"/>
    <xsl:choose>
      <xsl:when test="$res &gt;= 0">
        <func:result select="$res"/>
      </xsl:when>
      <xsl:otherwise>
        <func:result select="0"/>
      </xsl:otherwise>
    </xsl:choose>
  </func:function>
  
  <func:function name="a:search-end-range-nav">
    <xsl:param name="page"/>
    <xsl:param name="last-page"/>
    <xsl:param name="nav-range" select="o:get-search-nav-range()"/>
    <xsl:variable name="res" select="$page + $nav-range"/>
    <xsl:choose>
      <xsl:when test="$res &lt; $last-page">
        <func:result select="$res"/>
      </xsl:when>
      <xsl:otherwise>
        <func:result select="$last-page"/>
      </xsl:otherwise>
    </xsl:choose>
  </func:function>
  
  <xsl:template name="a:search-navigation">
    <xsl:param name="url"/>
    <xsl:param name="page"/>
    <xsl:param name="count"/>
    <xsl:param name="total"/>
    <xsl:param name="last-page" select="ceiling($total div $count)"/>    
    <xsl:param name="nav-range" select="o:get-search-nav-range()"/>  
    <xsl:param name="start-range" select="a:search-start-range-nav($page,$nav-range)"/>
    <xsl:param name="end-range" select="a:search-end-range-nav($page,$last-page,$nav-range)"/>  
    <xsl:if test="$page - $nav-range &gt;= 0">
      <li id='search_first'>
        <a href="{$url}&amp;page=0" title="{$o:nav-l10n[@key='first']}">
          <xsl:value-of select="$o:nav-l10n[@key='first-marker']"/>
        </a>
      </li>
    </xsl:if>
    <xsl:if test="$page &gt; $start-range">
      <li id='search_previous'>
        <a href="{$url}&amp;page={$page - 1}">
          <xsl:value-of select="$o:nav-l10n[@key='prev']"/>
        </a>
      </li>
    </xsl:if>        
    <xsl:call-template name="a:page-number">
      <xsl:with-param name="cur" select="$start-range"/>
      <xsl:with-param name="last-page" select="$end-range"/>
      <xsl:with-param name="page" select="$page"/>
      <xsl:with-param name="url" select="$url"/>
    </xsl:call-template>      
    <xsl:if test="$page &lt; $last-page - 1">
      <li id='search_next'>
        <a href="{$url}&amp;page={$page + 1}">
          <xsl:value-of select="$o:nav-l10n[@key='next']"/>
        </a>
      </li>
    </xsl:if>   
    <xsl:if test="$page + $nav-range &lt; $last-page">
      <li id='search_last'>
        <a href="{$url}&amp;page={$last-page - 1}" title="{$o:nav-l10n[@key='last']}">
          <xsl:value-of select="$o:nav-l10n[@key='last-marker']"/>
        </a>
      </li>
    </xsl:if>
  </xsl:template>
  
  <xsl:template name="a:page-number">
    <xsl:param name="cur" select="0"/>
    <xsl:param name="last-page"/>
    <xsl:param name="page"/>
    <xsl:param name="url"/>
    <xsl:if test="$cur &lt; $last-page">    
      <li>
        <xsl:choose>
          <xsl:when test="$cur = $page">
            <xsl:attribute name="class">current</xsl:attribute>
            <span><xsl:value-of select="$cur+1"/></span>
          </xsl:when>
          <xsl:otherwise>
            <a href="{$url}&amp;page={$cur}">
              <xsl:value-of select="$cur+1"/>
            </a>
          </xsl:otherwise>
        </xsl:choose>       
      </li>
      <xsl:call-template name="a:page-number">
        <xsl:with-param name="cur" select="$cur+1"/>
        <xsl:with-param name="page" select="$page"/>
        <xsl:with-param name="url" select="$url"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>  
  
  <xsl:template match="a:node[@key='all' and @node-id]" mode="a:search-list" name="a:search-list-node">    
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='search-list']/*"/>
    <xsl:param name="theme" select="$o:theme/l:context[@name='search-list']/*"/>
    <xsl:variable name="url" select="a:public-url(@uri)"/>
    <div class="actions-and-title">
      <!-- xsl:apply-templates select="a:node-acls/a:acl" mode="a:search-list-node-acl">
        <xsl:with-param name="url" select="$url"/>
        <xsl:with-param name="l10n" select="$l10n"/>
        <xsl:with-param name="theme" select="$theme"/>
      </xsl:apply-templates -->
            
      <div class='title'>
        <a href="{a:format-url($url)}" 
          title="{@tag}">
          <xsl:value-of select='a:title'/>
        </a>
        <div class='spacer'/>   
      </div>     
      <div class='spacer'/> 
    </div>
    
    <xsl:choose>
      <xsl:when test="string-length(@modified)">
        <div class='metadata modified'>
          <span>
            <xsl:value-of select='substring-before(a:format-date(@modified),"T")'/>
          </span>
          <div class='spacer'/>   
        </div>
        <xsl:if test="a:last-modifier">
          <div class='metadata agent last-modifier'>        
            <xsl:apply-templates select="a:last-modifier" mode="a:container-node-author">
              <xsl:with-param name="l10n" select="$l10n"/>
            </xsl:apply-templates>
            <div class='spacer'/>   
          </div>      
        </xsl:if> 
      </xsl:when>
      <xsl:when test="@created">
        <div class='metadata created'>
          <span>
            <xsl:value-of select='substring-before(a:format-date(@created),"T")'/>
          </span>
          <div class='spacer'/>   
        </div>       
        <xsl:if test="a:creator">
          <div class='metadata agent creator'>        
            <xsl:apply-templates select="a:creator" mode="a:container-node-author">
              <xsl:with-param name="l10n" select="$l10n"/>
            </xsl:apply-templates>
            <div class='spacer'/>   
          </div>      
        </xsl:if>          
      </xsl:when>
    </xsl:choose>  
      
    <div class="metadata description">
      <span>
        <xsl:value-of select="a:description"/>
      </span>
      <div class='spacer'/>
    </div>      
    
  </xsl:template>  
  
  <!-- xsl:template match="*" mode="a:search-list-node-acl"/>
  
  <xsl:template match="a:acl[@action='edit']" mode="a:search-list-node-acl">
    <xsl:param name="url"/>
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='search-list']/*"/>
    <xsl:param name="theme" select="$o:theme/l:context[@name='search-list']/*"/>
    <div class='action edit'>
      <a href="{a:format-url($url,'edit')}" 
        title="{$l10n[@key='edit']}">
        <xsl:variable name="edit-img" select="$theme[@key='edit']"/>
        <img class="action-image"
          src="{a:format-static-url(a:public-static-url($edit-img/@uri))}"
          alt="{$l10n[@key='edit']}"/>
      </a>          
      <div class='spacer'/>   
    </div>
  </xsl:template -->
  
  <xsl:template match="a:*[@node-id]" mode="a:container-node-author">
    <xsl:param name="key" select="local-name()"/>
    <xsl:param name="l10n"/>
    <span class="author-wo-profile">
      <xsl:choose>
        <xsl:when test="@nick">
          <xsl:value-of select='@nick'/>
        </xsl:when>
        <xsl:when test="@name">
          <xsl:value-of select='@name'/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select='$l10n[@key="unknown-user"]'/>
        </xsl:otherwise>
      </xsl:choose>            
    </span>                   
  </xsl:template> 
  
  <xsl:template match="a:*[a:profile]" mode="a:container-node-author">
    <xsl:param name="key" select="local-name()"/>
    <xsl:param name="l10n" select="$a:container-l10n"/>
    <a href="{a:format-url(a:public-url(a:profile/@uri))}" 
      title="{$l10n[@key=$key]}">
      <xsl:choose>
        <xsl:when test="@nick">
          <xsl:value-of select='@nick'/>
        </xsl:when>
        <xsl:when test="@name">
          <xsl:value-of select='@name'/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select='$l10n[@key="unknown-user"]'/>
        </xsl:otherwise>
      </xsl:choose>            
    </a>                   
  </xsl:template>
  
  <!-- removed a:range -->
  <xsl:template match="a:sort-direction|a:sort-by" mode="a:input-show" name="o:range">
    <xsl:param name="key" select="local-name()"/>
    <xsl:param name="options" select="$o:l10n/l:context[@name=$key]/*"/>    
    <div class="input {$key} select range">
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <xsl:value-of select="$o:params-l10n[@key=$key]"/>
          <div class='spacer'/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key=$key]"/>
          </xsl:call-template>
          <div class='spacer'/>
        </div>
        <div class="spacer"/>
      </div>  
      <div class="value">
        <xsl:apply-templates select="$options" mode="a:radio-select-by-position">
          <xsl:with-param name="name" select="$key"/>
          <xsl:with-param name="selected" select="number(@selected)"/>
        </xsl:apply-templates> 
        <div class="spacer"/>         
      </div>    
      <div class="spacer"/>
    </div>
  </xsl:template>  
    
  <!-- remove a:title, a:description -->
  <xsl:template match="a:query" mode="a:input-show">
    <!-- xsl:apply-templates select="." mode="a:input-methods"/ -->
    <xsl:variable name="key" select="local-name()"/>        
    <div class='input text {$key}'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <xsl:value-of select="$o:params-l10n[@key=$key]"/>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key=$key]"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class='spacer'/>
      </div>      
      <div class='value'>
        <input class='large' type="text" value="{.}" name="{$key}"/>
        <div class="value-help">
        <xsl:for-each select="$o:hints-l10n[@key='query-value']">
          <w:render-markup select="string(.)"
            mime-type='{@format}' 
            url-params-string='{$a:common-url-params}' 
            url-resource-ext='{$a:resource-ext}'/>
        </xsl:for-each>
        </div>
        <div class='spacer'/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
  
  <xsl:template match="a:page" mode="a:input-show"/>
  
  <xsl:template match="a:count" mode="a:input-show">          
    <div class='input text count'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <xsl:value-of select="$o:params-l10n[@key='count']"/>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='count']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class='spacer'/>
      </div>      
      <div class='value'>
        <select name="count">
          <xsl:call-template name="a:select-number">
            <xsl:with-param name="cur" select="number(@min)"/>
            <xsl:with-param name="max" select="number(@max)"/>
            <xsl:with-param name="step" select="number(@step)"/>
            <xsl:with-param name="selected" select="number(@selected)"/>
          </xsl:call-template>
        </select>
        <div class='spacer'/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template> 
   
  <xsl:template match="a:textindex-uri" mode="a:input-show"> 
    <xsl:param name="l10n" select="$o:l10n/*[@name='textindex-uri-ext']/*"/>    
    <div class='input textarea default-graph-uri'>      
      <div class='key'>
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$o:params-l10n[@key='textindex-uri']"/></span>
          <div class="spacer"/>
        </div>
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='textindex-uri']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='value'>
        <div class="entry">          
          <xsl:choose>
            <xsl:when test="*">
              <span>
                <xsl:variable name="markup" select="$l10n[@key='has-defaults']"/>
                <w:render-markup select="string($markup)" 
                  mime-type="{$markup/@format}"
                  url-params-string='{$a:common-url-params}' 
                  url-resource-ext='{$a:resource-ext}'/>
              </span>              
              <xsl:for-each select="*">
                <div class='checkbox-input'>
                  <input type='checkbox' name='textindex-uri' value='{@key}'>
                    <xsl:if test="@selected">
                      <xsl:attribute name="checked">checked</xsl:attribute>
                    </xsl:if>
                    <xsl:choose>
                      <xsl:when test="@uri">
                        <a href="{a:format-url(a:public-url(@uri))}" title="{$l10n[@key='description-link-title']}">
                          <xsl:if test="@default">
                            <xsl:attribute name="class">default</xsl:attribute>
                          </xsl:if>
                          <xsl:value-of select="."/>
                        </a>
                      </xsl:when>    
                      <xsl:otherwise>
                        <span>
                          <xsl:if test="@default">
                            <xsl:attribute name="class">default</xsl:attribute>
                          </xsl:if>
                          <xsl:value-of select="."/>
                        </span>
                      </xsl:otherwise>                  
                    </xsl:choose>               
                  </input>
                </div>
              </xsl:for-each>              
            </xsl:when>
            <xsl:otherwise>
              <span>
                <xsl:variable name="markup" select="$l10n[@key='no-defaults']"/>
                <w:render-markup select="string($markup)" 
                  mime-type="{$markup/@format}"
                  url-params-string='{$a:common-url-params}' 
                  url-resource-ext='{$a:resource-ext}'/>
              </span>
            </xsl:otherwise>
          </xsl:choose>          
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>    
  </xsl:template> 
  
  <!-- publish dates -->
  <!-- xsl:template match="a:publishPeriod" mode="a:search-url-param-str">
    <xsl:if test="@use">
      <xsl:value-of select="'&amp;use-publish-period=1'"/>
    </xsl:if>
    <xsl:apply-templates mode="a:publish-period-param"/>
  </xsl:template>
  
  <xsl:template match="*" mode="a:publish-period-param">
    <xsl:param name="name" select="local-name()"/>
    <xsl:param name="date" select="string(.)"/>
    <xsl:choose>
      <xsl:when test="string-length($date)">
        <xsl:apply-templates select="date:tokenize(date:adjust-date-to-timezone($a:timezone,$date))" mode="dt:input-hidden">
          <xsl:with-param name="name" select="$name"/>
        </xsl:apply-templates>
      </xsl:when>
      <xsl:otherwise>
        <xsl:variable name="ud">
          <y/><M/><d/><H/><m/><s/><z/>
        </xsl:variable>
        <xsl:apply-templates select="exslt:node-set($ud)/*" mode="a:publish-period-parts-param">
          <xsl:with-param name="name" select="$name"/>
        </xsl:apply-templates>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template> 
  
  <xsl:template match="*" mode="a:publish-period-parts-param">
    <xsl:param name="name"/>
    <xsl:value-of select="concat('&amp;',$name,'-',local-name(),'=',.)"/>
  </xsl:template>  
  
  <xsl:template match="s" mode="dt:input-hidden"/>
  <xsl:template match="s" mode="dt:input"/>
  
  <xsl:template match="a:publishPeriod" mode="a:input-show">
    <xsl:param name="config"/>
    <div class='input text publish-period'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$o:params-l10n[@key='publish-period']"/></span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='publish-period']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='value'>
        <div class='entry use-publish-period'>
          <input type="checkbox" name="use-publish-period" value="1">
            <xsl:if test="@use">
              <xsl:attribute name="checked">checked</xsl:attribute>
            </xsl:if>
          </input>
          <span>
            <xsl:value-of select="$o:hints-l10n[@key='use-publish-period']"/>
          </span>
          <div class='spacer'/>
        </div>
        <xsl:apply-templates mode="a:publishPeriod-input-show">
          <xsl:with-param name="config" select="$config"/>
        </xsl:apply-templates>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
   
  <xsl:template match="a:startDate|a:endDate" mode="a:publishPeriod-input-show">    
    <xsl:param name="key" select="local-name()"/>
    <xsl:param name="config" select="/*/a:config"/>
    <div class='entry {$key}'>  
      <div class="header">
        <div>
          <xsl:call-template name="a:label-class-attr">
            <xsl:with-param name="class" select="'key'"/>
          </xsl:call-template>
          <span><xsl:value-of select="$o:params-l10n[@key=$key]"/></span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key=$key]"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='options'>
        <xsl:call-template name="dt:input">
          <xsl:with-param name="name" select="$key"/>
          <xsl:with-param name="config" select="$config"/>
        </xsl:call-template>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
  
  <xsl:template match="a:publishPeriod" mode="a:input-hidden">
    <xsl:if test="@use">
      <input type="hidden" name="use-publishPeriod" value="1"/>
    </xsl:if>
    <xsl:apply-templates mode="dt:input-hidden"/>
  </xsl:template -->
  
  <!-- xsl:template match="a:effectiveDate" mode="a:input-hidden">
    <xsl:if test="@selected='1'">
      <input type='hidden' name='efdFlag' value='1'/>
    </xsl:if>
    <input type='hidden' name='efdYr' value='{@year}'/>
    <input type='hidden' name='efdMon' value='{@mon}'/>
  </xsl:template>
  
  <xsl:template match="a:effectiveDate" mode="a:input-show">
    <xsl:param name="config"/>
    <div class='input text publish-period'>  
      <div class="key">
        <div>
          <xsl:call-template name="a:label-class-attr"/>
          <span><xsl:value-of select="$o:params-l10n[@key='effectiveDate']"/></span>
          <div class="spacer"/>
        </div>        
        <div class='hint'>
          <xsl:call-template name="a:input-hints">
            <xsl:with-param name="hint" select="$o:hints-l10n[@key='effectiveDate']"/>
          </xsl:call-template>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>      
      <div class='value'>
        <div class='entry efdFlag'>
          <input type="checkbox" name="efdFlag" value="1">
            <xsl:if test="@selected">
              <xsl:attribute name="checked">checked</xsl:attribute>
            </xsl:if>
          </input>
          <span>
            <xsl:value-of select="$o:hints-l10n[@key='efdFlag']"/>
          </span>
          <div class='spacer'/>
        </div>
        <xsl:call-template name="o:efdYr-input"/>
        <xsl:call-template name="o:efdMon-input"/>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
  
  <xsl:template name="o:efdYr-input">    
    <div class='entry date efdYr'>  
      <div class="header">
        <div>
          <xsl:call-template name="a:label-class-attr">
            <xsl:with-param name="class" select="'key'"/>
          </xsl:call-template>
          <span><xsl:value-of select="$o:params-l10n[@key='efdYr']"/></span>
          <div class="spacer"/>
        </div> 
        <div class="spacer"/>
      </div>      
      <div class='options'>
        <select name='efdYr'>
          <xsl:call-template name="o:efdYr-opts">
            <xsl:with-param name="cur" select="number(@start-year)"/>
            <xsl:with-param name="end" select="number(@end-year)"/>
            <xsl:with-param name="sel" select="number(@year)"/>
          </xsl:call-template>
        </select>
        <div class="spacer"/>
      </div>
      <div class='spacer'/>
    </div>
  </xsl:template>
  
  <xsl:template name="o:efdYr-opts">
    <xsl:param name="cur"/>
    <xsl:param name="end"/>    
    <xsl:param name="sel"/>
    <xsl:if test="$cur &lt;= $end">
      <option>
        <xsl:if test="$cur = $sel">
          <xsl:attribute name="selected">selected</xsl:attribute>
        </xsl:if>
        <xsl:value-of select="$cur"/>
      </option>
      <xsl:call-template name="o:efdYr-opts">
        <xsl:with-param name="cur" select="$cur+1"/>
        <xsl:with-param name="end" select="$end"/>
        <xsl:with-param name="sel" select="$sel"/>
      </xsl:call-template>
    </xsl:if>
  </xsl:template>
  
  <xsl:template name="o:efdMon-input">
    <xsl:param name="selected" select="number(@mon)"/>
    <div class="entry date efdMon">
      <div class="header">
        <div>
          <xsl:call-template name="a:label-class-attr">
            <xsl:with-param name="class" select="'key'"/>
          </xsl:call-template>
          <span>
            <xsl:value-of select="$o:params-l10n[@key='efdMon']"/>
          </span>
          <div class="spacer"/>
        </div>
        <div class="spacer"/>
      </div>
      <div class="options">
        <select name="efdMon">
          <xsl:for-each select="$o:dates-l10n/*[@name='date-month-abbrev']/*">
            <option value="{@key}">
              <xsl:if test="@key = $selected">
                <xsl:attribute name="selected">selected</xsl:attribute>
              </xsl:if>
              <xsl:value-of select="."/>
            </option>
          </xsl:for-each>         
        </select>
        <div class="spacer"/>
      </div>     
      <div class="spacer"/>
    </div>
  </xsl:template -->
  
  <xsl:template match="a:submit[@key='search' or @key='refresh' or @key='change-query']">    
    <xsl:param name="name"/>    
    <xsl:param name='key' select='@key'/>
    <div class="input submit">
      <xsl:variable name='val' select='$o:submits-l10n[@key=$key]'/>
      <input type='hidden' name='{$key}' value='{$val}'/>
      <input type='submit' name='{$name}' value='{$val}'/>
      <div class='spacer'/>
    </div>        
  </xsl:template> 
  
  <xsl:template match="*" mode="a:form-related-request">
    <xsl:param name="l10n" select="$o:l10n/l:context[@name='form-related-requests']/*"/>
    <div class="form-related-request form-reset">
      <a href="{a:format-reset-request()}">
        <xsl:value-of select="$l10n[@key='reset']"/>
      </a>
      <div class="spacer"/>
    </div>
  </xsl:template>
  
</xsl:stylesheet>

